package com.wan.lession56.web.controller;

import com.wan.lession56.entity.User;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
@RequestMapping("/demo")
public class DemoController {
    private UserServices userServices;
    @RequestMapping("/a")
    public String xxx() throws Exception {
        int i=1;
        if (i==1){
            throw new Exception("出现了类型转换异常");
        }
        return "娃哈哈";
    }

    @RequestMapping("/b")
    public User getUser() throws NullPointerException{
        User user = null;
        int i=1;
        if (i==1){
            throw new NullPointerException("出现空指针了");
        }
        return user;
    }

    @RequestMapping("/addUser")
    public String addUser(@RequestBody User user) {
        System.out.println(user);
        return "哈哈哈";
    }

    @RequestMapping("/addUserList")
    public String addUserList(@RequestBody List<User> userList) {
        System.out.println(userList);
        return "哦呵呵";
    }
}
